/*
 * @Author: your name
 * @Date: 2022-01-01 00:55:43
 * @LastEditTime: 2022-01-01 00:55:44
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \json-serveg:\桌面2\TypeScript\part2\src\moduls\ScorePanel.ts
 */
// 定义记分牌的类
class ScorePanel{
    // score和level用来记录分数和等级
    score = 0 
    level = 1

    scoreEl : HTMLElement
    levelEl : HTMLElement

    constructor(){
        this.scoreEl = document.getElementById('score')!
        this.levelEl = document.getElementById('level')!
    }

    //设置一个加分的方法
    addScore(){
        //分数自增
        this.scoreEl.innerHTML = ++this.score + ''
        //判断多少分升一级
        if (this.score % 10 === 0) {
            this.addLevel()
        }

    }

    //等级的提升方法
    addLevel(){
        if (this.level < 10) {
            this.levelEl.innerHTML = ++this.level + ''
        }
        
    }

}

// const scorePanel = new ScorePanel()
// scorePanel.addScore()
// scorePanel.addScore()
// scorePanel.addLevel()

export default ScorePanel